//
// Created by zhouwd on 2019/6/21.
//

#ifndef IPTVSETTING_RENDER_H
#define IPTVSETTING_RENDER_H
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include <cstdlib>
#include <cstring>
#include <jni.h>
#include <android/log.h>
#define LOG_TAG "CAMERA-RENDER"
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

typedef class _RENDER {
private:

    int mWidth, mHeight;
    size_t yBufferSize, uBufferSize, vBufferSize;
    uint8_t *yBuffer,*uBuffer,*vBuffer;
    GLuint id_y, id_u, id_v, program; // Texture id
    GLint textureUniformY, textureUniformU, textureUniformV;
    GLuint createShader(GLenum shaderType, const char* src);
    GLuint createProgram(const char* vtxSrc, const char* fragSrc);
public:
    int init(int width, int height, char *mPreviewFragmentShaderBuffer,char *mPreviewVertexShaderBuffer);

    int step();

    int resize();

    int updateFrameData(jbyte *data);
} Render;


#endif //IPTVSETTING_RENDER_H
